--- D:/xampp/htdocs/tvtools/sites/default/modules/contrib/comment_driven/comment_driven.module.alpha2.orig	Sun Apr 04 02:21:22 2010
+++ D:/xampp/htdocs/tvtools/sites/default/modules/contrib/comment_driven/comment_driven.module	Wed Apr 14 18:41:31 2010
@@ -81,10 +81,21 @@
       driven_props_delete_settings($driver_mod, $node_type);
       break;
   }
 }
 
+/**
+ * Implements hook_theme().
+ */
+function comment_driven_theme() {
+  return array(
+    'comment_driven_proxy' => array(
+      'arguments' => array('element' => NULL),
+    ),
+  );
+}
+
 ///\\\///\\\///\\\///\\\///
 
 /**
  * Implements hook_form_alter().
  */
@@ -189,11 +200,14 @@
   return driven_props_get_type_setting($driver_mod, $node_type, $name, $default);
 }
 
 function _comment_driven_disguise_children($element) {
   // @TODO: every call to comment_driven_assertion_failed will be removed after alpha/beta stage 
-  if (!is_array($element)) comment_driven_assertion_failed('something nasty is happening somewhere: !is_array($element)');
+  if (!is_array($element)) {
+    comment_driven_assertion_failed('something nasty is happening somewhere: !is_array($element)');
+    return;
+  }
   
   // adjust #parents to match the disguised elements of comment_form
   // note that no parent would point to a level above the comment_form
   _comment_driven_disguise_adjust_parents($element);
   
@@ -206,11 +220,20 @@
       continue; // no need to recursive disguise
     }
     // protect ourself against 3rd parties creating NULL children (e.g. [#736968], [#737044])
     // lets babysit NULL children, but it has to be an array otherwise
     if (!is_null($element[$key])) {
-      $element[COMMENT_DRIVEN__DISGUISE_PREFIX . $key] = _comment_driven_disguise_children($element[$key]);
+      $disguised_child = _comment_driven_disguise_children($element[$key]);
+      if (isset($disguised_child['#theme'])) {
+        // disguise_children supports only element_children
+        // (disguise_form_values doesn't address non-children either) 
+        // undisguise does support non-children as well
+        // manually disguise non-children
+        $disguised_child['#' . COMMENT_DRIVEN__DISGUISE_PREFIX . '#theme'] = $disguised_child['#theme'];
+        $disguised_child['#theme'] = 'comment_driven_proxy'; 
+      }
+      $element[COMMENT_DRIVEN__DISGUISE_PREFIX . $key] = $disguised_child;
     }
     // if it was NULL (above babysitting) won't hurt clearing it
     unset($element[$key]);
   }
   return $element;
@@ -222,10 +245,22 @@
   if (!empty($element['#parents'])) {
     foreach ($element['#parents'] as $index => $parent) {
       $element['#parents'][$index] = COMMENT_DRIVEN__DISGUISE_PREFIX . $parent;
     }
   }
+}
+
+function theme_comment_driven_proxy($element) {
+  // key #theme is expected to be overriden by its disguised version
+  // but, just in case, lets ensure we won't fall back here (unintended recursion) 
+  unset($element['#theme']);
+
+  // Also need to set #theme_used to false, so drupal render doesnt get confused when it does the real theming
+  $element['#theme_used'] = false;
+
+  $element = _comment_driven_undisguise($element);
+  return drupal_render($element);
 }
 
 // helper function to drive properties programmatically [#741274] 
 function comment_driven_disguise_form_values($arr) {
   // @TODO: every call to comment_driven_assertion_failed will be removed after alpha/beta stage 
